\ ******************************************************
\
\ Definition of pieces
\
\ Note all pieces are assumed to have the same number of dots.
\
\ ******************************************************

\ mdh - slight mods to be compatible with new locals (v2.0+) in beta state,
\       everything still works with V2.0 and earlier.  Final v2.0+ locals
\       will be completely backward-compatible.


ANEW Task-Pieces

4 CONSTANT DotsPerPiece
2 CELL * DotsPerPiece * CONSTANT SinglePieceSize

: getDcr { addrOfPiece rotationNr dotnr | Dc Dr -- Dc Dr }
\ give relative position of individual dots
   rotationNr SinglePieceSize *
   2 CELL * dotNr * + addrOfPiece +
   dup @ -> Dc
   CELL + @ -> Dr
   Dc Dr  \ added mdh
;

: ,, ( a b -- store a & b at here, a first)
   swap , ,
;

CREATE Piece0
 0 -2 ,,    0 -1 ,,    0  0 ,,    0  1 ,,
 2  0 ,,    1  0 ,,    0  0 ,,   -1  0 ,,
 2  2 ,,    1  1 ,,    0  0 ,,   -1 -1 ,,
 0  2 ,,    0  1 ,,    0  0 ,,    0 -1 ,,
-2  0 ,,   -1  0 ,,    0  0 ,,    1  0 ,,
-2 -2 ,,   -1 -1 ,,    0  0 ,,    1  1 ,,


CREATE Piece1
 0 , -1 ,    0 ,  0 ,     1 ,  1 ,     1 ,  2 ,
 1 ,  0 ,    0 ,  0 ,     0 ,  1 ,    -1 ,  1 ,
 1 ,  1 ,    0 ,  0 ,    -1 ,  0 ,    -2 , -1 ,
 0 ,  1 ,    0 ,  0 ,    -1 , -1 ,    -1 , -2 ,
-1 ,  0 ,    0 ,  0 ,     0 , -1 ,     1 , -1 ,
-1 , -1 ,    0 ,  0 ,     1 ,  0 ,     2 ,  1 ,


CREATE Piece2
 0 -1 ,,    0  0 ,,   -1  0 ,,   -1  1 ,,
 1  0 ,,    0  0 ,,   -1 -1 ,,   -2 -1 ,,
 1  1 ,,    0  0 ,,    0 -1 ,,   -1 -2 ,,
 0  1 ,,    0  0 ,,    1  0 ,,    1 -1 ,,
-1  0 ,,    0  0 ,,    1  1 ,,    2  1 ,,
-1 -1 ,,    0  0 ,,    0  1 ,,    1  2 ,,

CREATE Piece3  ( Its all symetric! )
-1 -1 ,,    0  0 ,,    1  0 ,,    0  1 ,,
 0 -1 ,,    0  0 ,,   -1  0 ,,    1  1 ,,
-1 -1 ,,    0  0 ,,    1  0 ,,    0  1 ,,
 0 -1 ,,    0  0 ,,   -1  0 ,,    1  1 ,,
-1 -1 ,,    0  0 ,,    1  0 ,,    0  1 ,,
 0 -1 ,,    0  0 ,,   -1  0 ,,    1  1 ,,

CREATE Piece4
 0 -1 ,,    0  0 ,,   -1 -1 ,,    1  0 ,,
 1  0 ,,    0  0 ,,    0 -1 ,,    1  1 ,,
 1  1 ,,    0  0 ,,    1  0 ,,    0  1 ,,
 0  1 ,,    0  0 ,,   -1  0 ,,    1  1 ,,
-1  0 ,,    0  0 ,,    0  1 ,,   -1 -1 ,,
-1 -1 ,,    0  0 ,,   -1  0 ,,    0 -1 ,,

CREATE Piece5
-1 -1 ,,    0 -1 ,,    1  0 ,,    1  1 ,,
 0 -1 ,,    1  0 ,,    1  1 ,,    0  1 ,,
 1  0 ,,    1  1 ,,    0  1 ,,   -1  0 ,,
 1  1 ,,    0  1 ,,   -1  0 ,,   -1 -1 ,,
 0  1 ,,   -1  0 ,,   -1 -1 ,,    0 -1 ,,
-1  0 ,,   -1 -1 ,,    0 -1 ,,    1  0 ,,

CREATE Piece6
-1 -1 ,,    0  0 ,,    0  1 ,,    0  2 ,,
 0 -1 ,,    0  0 ,,   -1  0 ,,   -2  0 ,,
 1  0 ,,    0  0 ,,   -2 -2 ,,   -1 -1 ,,
 1  1 ,,    0  0 ,,    0 -1 ,,    0 -2 ,,
 0  1 ,,    0  0 ,,    2  0 ,,    1  0 ,,
-1  0 ,,    0  0 ,,    1  1 ,,    2  2 ,,

CREATE Piece7
 1  0 ,,    0  0 ,,    0  1 ,,    0  2 ,,
 1  1 ,,    0  0 ,,   -1  0 ,,   -2  0 ,,
 0  1 ,,    0  0 ,,   -1 -1 ,,   -2 -2 ,,
-1  0 ,,    0  0 ,,    0 -1 ,,    0 -2 ,,
-1 -1 ,,    0  0 ,,    1  0 ,,    2  0 ,,
 0 -1 ,,    0  0 ,,    1  1 ,,    2  2 ,,

CREATE Piece8
-1 -1 ,,    0 -1 ,,    0  0 ,,    0  1 ,,
 0 -1 ,,    1  0 ,,    0  0 ,,   -1  0 ,,
 1  0 ,,    1  1 ,,    0  0 ,,   -1 -1 ,,
 1  1 ,,    0  1 ,,    0  0 ,,    0 -1 ,,
 0  1 ,,   -1  0 ,,    0  0 ,,    1  0 ,,
-1  0 ,,   -1 -1 ,,    0  0 ,,    1  1 ,,


CREATE Piece9
 1  0 ,,    0 -1 ,,    0  0 ,,    0  1 ,,
 1  1 ,,    1  0 ,,    0  0 ,,   -1  0 ,,
 0  1 ,,    1  1 ,,    0  0 ,,   -1 -1 ,,
-1  0 ,,    0  1 ,,    0  0 ,,    0 -1 ,,
-1 -1 ,,   -1  0 ,,    0  0 ,,    1  0 ,,
 0 -1 ,,   -1 -1 ,,    0  0 ,,    1  1 ,,



10 ARRAY Pieces

: init-pieces ( To make it CLONE compatible )
    Piece0   0 Pieces !
    Piece1   1 Pieces !
    Piece2   2 Pieces !
    Piece3   3 Pieces !
    Piece4   4 Pieces !
    Piece5   5 Pieces !
    Piece6   6 Pieces !
    Piece7   7 Pieces !
    Piece8   8 Pieces !
    Piece9   9 Pieces !
;

: .piece { addr -- }  \ had to add '--' mdh
   cr
   6 0 DO
      4 0 DO
         addr j i getDcr swap 3 .r 3 .r 5 spaces
      LOOP
      cr
   LOOP
;

